import axios from 'axios'

export default {
  createAxios(appConfig) {
    const defaultTimeout = 60000

    const http_service = axios.create({
      timeout: defaultTimeout
    })
    http_service.interceptors.request.use(config => {
      const headers = config.headers
      const customHeaders = {}
      for (const key in headers) {
        if (!/common|delete|get|head|post|put|patch/.test(key)) {
          customHeaders[key] = headers[key]
        }
      }
      return config
    })
    http_service.interceptors.response.use(rsp => rsp.data, error => Promise.reject(error))
    return http_service
  }
}
